import { dataMapper } from '../../../src/utils/publicFun.ts'

/**
 * 一级分类
 * @returns
 */
const getPrimaryClassification = () => {
  return [
    {
      token: 'Admin Token',
      city: [
        {
          id: 1,
          name: '图书/音像/电子书',
        },
        {
          id: 2,
          name: '手机',
        },
        {
          id: 3,
          name: '上衣',
        },
        {
          id: 4,
          name: '裤子',
        },
        {
          id: 5,
          name: '鞋子',
        },
        {
          id: 6,
          name: '电脑办公',
        },
      ],
    },
  ]
}

/**
 *
 * @returns 二级分类
 */
const getSecondaryClassification = () => {
  return [
    {
      token: 'Admin Token',
      primaryId: 1, //一级分类名称：图书/音像/电子书
      city: [
        {
          id: 1,
          name: '论文',
        },
        {
          id: 2,
          name: '小说',
        },
        {
          id: 3,
          name: '诗词',
        },
        {
          id: 4,
          name: '史学',
        },
      ],
    },
    {
      token: 'Admin Token',
      primaryId: 2, //一级分类名称：手机
      city: [
        {
          id: 5,
          name: '手机配件',
        },
        {
          id: 6,
          name: '手机通讯', //手机、对讲机、有线电话
        },
        {
          id: 7,
          name: '运营商',
        },
      ],
    },

    {
      token: 'Admin Token',
      primaryId: 3, //一级分类名称：上衣
      city: [
        {
          id: 8,
          name: '内上衣',
        },
        {
          id: 9,
          name: '外上衣', //手机、对讲机、有线电话
        },
        {
          id: 10,
          name: '中西式上衣',
        },
      ],
    },

    {
      token: 'Admin Token',
      primaryId: 4, //一级分类名称：裤子
      city: [
        {
          id: 11,
          name: '冬季裤子',
        },
        {
          id: 12,
          name: '夏季裤子', //手机、对讲机、有线电话
        },
        {
          id: 13,
          name: '秋季裤子',
        },
      ],
    },

    {
      token: 'Admin Token',
      primaryId: 5, //一级分类名称：鞋子
      city: [
        {
          id: 14,
          name: '冬季鞋子',
        },
        {
          id: 15,
          name: '夏季鞋子', //手机、对讲机、有线电话
        },
        {
          id: 16,
          name: '秋季鞋子',
        },
      ],
    },

    {
      token: 'Admin Token',
      primaryId: 6, //一级分类名称：办公电脑
      city: [
        {
          id: 17,
          name: '台式电脑',
        },
        {
          id: 18,
          name: '笔记本电脑',
        },
      ],
    },
  ]
}

/**
 *
 * @returns 三级分类
 */
const getReclassifClassification = () => {
  return [
    {
      token: 'Admin Token',
      primaryId: 1, //二级分类名称：论文
      city: [
        {
          id: 1,
          name: '互联网',
        },
        {
          id: 2,
          name: '历史论文',
        },
        {
          id: 3,
          name: '人文',
        },
        {
          id: 4,
          name: '医疗',
        },
      ],
    },
    {
      token: 'Admin Token',
      primaryId: 2, //二级分类名称：小说
      city: [
        {
          id: 5,
          name: '悬疑',
        },
        {
          id: 6,
          name: '惊恐',
        },
        {
          id: 7,
          name: '爽文',
        },
        {
          id: 8,
          name: '科幻',
        },
      ],
    },
    {
      token: 'Admin Token',
      primaryId: 3, //二级分类名称：诗词
      city: [
        {
          id: 5,
          name: '抒情',
        },
        {
          id: 6,
          name: '描写',
        },
        {
          id: 7,
          name: '议论',
        },
        {
          id: 8,
          name: '叙述',
        },
      ],
    },
    {
      token: 'Admin Token',
      primaryId: 4, //二级分类名称：史学
      city: [
        {
          id: 9,
          name: '中国史学',
        },
        {
          id: 10,
          name: '国历史',
        },
        {
          id: 11,
          name: '世界史',
        },
        {
          id: 12,
          name: '考古学',
        },
      ],
    },

    {
      token: 'Admin Token',
      primaryId: 5, //二级分类名称：手机配件
      city: [
        {
          id: 9,
          name: '触摸屏',
        },
        {
          id: 10,
          name: '机壳',
        },
        {
          id: 11,
          name: '电池',
        },
        {
          id: 12,
          name: '耳机',
        },
        {
          id: 13,
          name: '充电器',
        },
      ],
    },

    {
      token: 'Admin Token',
      primaryId: 6, //二级分类名称：手机通讯
      city: [
        {
          id: 14,
          name: '手机',
        },
        {
          id: 15,
          name: '对讲机',
        },
        {
          id: 16,
          name: '有线电话',
        },
      ],
    },

    {
      token: 'Admin Token',
      primaryId: 7, //二级分类名称：运营商
      city: [
        {
          id: 17,
          name: '华为',
        },
        {
          id: 18,
          name: '中兴',
        },
        {
          id: 19,
          name: '爱立信',
        },
      ],
    },
    {
      token: 'Admin Token',
      primaryId: 8, //二级分类名称：内上衣
      city: [
        {
          id: 20,
          name: '汗衫',
        },
        {
          id: 21,
          name: '棉毛衫',
        },
      ],
    },
    {
      token: 'Admin Token',
      primaryId: 9, //二级分类名称：外上衣
      city: [
        {
          id: 22,
          name: '中山装',
        },
        {
          id: 23,
          name: '西装',
        },
        {
          id: 24,
          name: '学生装',
        },
      ],
    },
    {
      token: 'Admin Token',
      primaryId: 10, //二级分类名称：中西式上衣
      city: [
        {
          id: 25,
          name: '中式西装',
        },
        {
          id: 26,
          name: '中西式学生装',
        },
      ],
    },
    {
      token: 'Admin Token',
      primaryId: 11, //二级分类名称：冬季裤子
      city: [
        {
          id: 27,
          name: '直筒',
        },
        {
          id: 28,
          name: '小脚裤',
        },
      ],
    },
    {
      token: 'Admin Token',
      primaryId: 12, //二级分类名称：夏季裤子
      city: [
        {
          id: 29,
          name: '中式西装',
        },
        {
          id: 30,
          name: '中西式学生装',
        },
      ],
    },
    {
      token: 'Admin Token',
      primaryId: 13, //二级分类名称：秋季裤子
      city: [
        {
          id: 31,
          name: '直筒秋裤',
        },
        {
          id: 32,
          name: '紧身秋裤',
        },
      ],
    },
    {
      token: 'Admin Token',
      primaryId: 14, //二级分类名称：冬季鞋子
      city: [
        {
          id: 33,
          name: '靴子',
        },
        {
          id: 34,
          name: '羽绒运动鞋',
        },
      ],
    },
    {
      token: 'Admin Token',
      primaryId: 15, //二级分类名称：夏季鞋子
      city: [
        {
          id: 33,
          name: '靴子',
        },
        {
          id: 34,
          name: '羽绒运动鞋',
        },
      ],
    },
    {
      token: 'Admin Token',
      primaryId: 17, //二级分类名称：台式电脑
      city: [
        {
          id: 33,
          name: '靴子',
        },
        {
          id: 34,
          name: '羽绒运动鞋',
        },
      ],
    },
    {
      token: 'Admin Token',
      primaryId: 17, //二级分类名称：台式电脑
      city: [
        {
          id: 33,
          name: '靴子',
        },
        {
          id: 34,
          name: '羽绒运动鞋',
        },
      ],
    },

    {
      token: 'Admin Token',
      primaryId: 18, //二级分类名称：笔记本电脑
      city: [
        {
          id: 33,
          name: '轻薄本笔记本',
        },
        {
          id: 34,
          name: '高性能笔记本',
        },
      ],
    },
  ]
}

/**
 *
 * @returns 属性数据
 */
const getPropertyData = () => {
  return [
    {
      token: 'Admin Token',
      primaryId: 1, //二级分类名称：互联网
      city: [
        {
          id: 1,
          property: '云服务论文',
          propertyTitle1: [
            {
              id: 1,
              content: '云服务11',
            },
            {
              id: 2,
              content: '云服务22',
            },
            {
              id: 3,
              content: '云服务231',
            },
            {
              id: 4,
              content: '云服务21245',
            },
            {
              id: 5,
              content: '云服务78',
            },
          ],
        },
        {
          id: 2,
          property: '互联网软件论文',
          propertyTitle1: [
            {
              id: 1,
              content: '互联网软件11',
            },
            {
              id: 2,
              content: '互联网软件22',
            },
            {
              id: 3,
              content: '互联网软件231',
            },
            {
              id: 4,
              content: '互联网软件21245',
            },
          ],
        },
        {
          id: 3,
          property: '互联网+论文',
          propertyTitle1: [
            {
              id: 1,
              content: '互联网+AI',
            },
            {
              id: 2,
              content: '互联网+语音识别',
            },
            {
              id: 3,
              content: '互联网+硬件',
            },
            {
              id: 4,
              content: '互联网+企业',
            },
            {
              id: 5,
              content: '互联网+',
            },
          ],
        },
      ],
    },
    {
      token: 'Admin Token',
      primaryId: 2, //二级分类名称：历史
      city: [
        {
          id: 1,
          property: '近代史论文',
          propertyTitle1: [
            {
              id: 1,
              content: '史学论文4',
            },
            {
              id: 2,
              content: '史学论文5',
            },
            {
              id: 3,
              content: '史学论文3',
            },
          ],
        },
        {
          id: 2,
          property: '古代史论文',
          propertyTitle1: [
            {
              id: 1,
              content: '古代史论文1',
            },
            {
              id: 2,
              content: '古代史论文2',
            },
            {
              id: 3,
              content: '古代史论文3',
            },
          ],
        },
      ],
    },
    {
      token: 'Admin Token',
      primaryId: 3, //二级分类名称：人文
      city: [
        {
          id: 1,
          property: '中国哲学论文',
          propertyTitle1: [
            {
              id: 1,
              content: '古代史论文1',
            },
            {
              id: 2,
              content: '古代史论文2',
            },
            {
              id: 3,
              content: '古代史论文3',
            },
          ],
        },
        {
          id: 2,
          property: '大国工匠论文',
          propertyTitle1: [
            {
              id: 1,
              content: '大国工匠论文12',
            },
            {
              id: 2,
              content: '大国工匠论文12',
            },
            {
              id: 3,
              content: '大国工匠论文2',
            },
          ],
        },
        {
          id: 3,
          property: '123论文',
          propertyTitle1: [
            {
              id: 1,
              content: '123论文121',
            },
            {
              id: 2,
              content: '123论文45',
            },
            {
              id: 3,
              content: '123论文12',
            },
          ],
        },
        {
          id: 4,
          property: '叙述论文',
          propertyTitle1: [
            {
              id: 1,
              content: '叙述论文as',
            },
            {
              id: 2,
              content: '叙述论文12',
            },
            {
              id: 3,
              content: '古代史论文3545',
            },
          ],
        },
      ],
    },
    {
      token: 'Admin Token',
      primaryId: 4, //二级分类名称：医疗
      city: [
        {
          id: 9,
          property: '中医医疗',
          propertyTitle1: [
            {
              id: 1,
              content: '123论文121',
            },
            {
              id: 2,
              content: '123论文45',
            },
            {
              id: 3,
              content: '123论文12',
            },
          ],
        },
        {
          id: 10,
          property: '西医医疗',
          propertyTitle1: [
            {
              id: 1,
              content: '123论文121',
            },
            {
              id: 2,
              content: '123论文45',
            },
            {
              id: 3,
              content: '123论文12',
            },
          ],
        },
        {
          id: 11,
          property: '中西医疗设备',
          propertyTitle1: [
            {
              id: 1,
              content: '123论文121',
            },
            {
              id: 2,
              content: '123论文45',
            },
            {
              id: 3,
              content: '123论文12',
            },
          ],
        },
      ],
    },

    {
      token: 'Admin Token',
      primaryId: 5, //二级分类名称：悬疑小说
      city: [
        {
          id: 9,
          property: '中医医疗',
          propertyTitle1: [
            {
              id: 1,
              content: '123论文121',
            },
            {
              id: 2,
              content: '123论文45',
            },
            {
              id: 3,
              content: '123论文12',
            },
          ],
        },
        {
          id: 10,
          property: '西医医疗',
          propertyTitle1: [
            {
              id: 1,
              content: '123论文121',
            },
            {
              id: 2,
              content: '123论文45',
            },
            {
              id: 3,
              content: '123论文12',
            },
          ],
        },
        {
          id: 11,
          property: '中西医疗设备',
          propertyTitle1: [
            {
              id: 1,
              content: '123论文121',
            },
            {
              id: 2,
              content: '123论文45',
            },
            {
              id: 3,
              content: '123论文12',
            },
          ],
        },
      ],
    },

    {
      token: 'Admin Token',
      primaryId: 6, //二级分类名称：手机通讯
      city: [
        {
          id: 9,
          property: '中医医疗',
          propertyTitle1: [
            {
              id: 1,
              content: '123论文121',
            },
            {
              id: 2,
              content: '123论文45',
            },
            {
              id: 3,
              content: '123论文12',
            },
          ],
        },
        {
          id: 10,
          property: '西医医疗',
          propertyTitle1: [
            {
              id: 1,
              content: '123论文121',
            },
            {
              id: 2,
              content: '123论文45',
            },
            {
              id: 3,
              content: '123论文12',
            },
          ],
        },
        {
          id: 11,
          property: '中西医疗设备',
          propertyTitle1: [
            {
              id: 1,
              content: '123论文121',
            },
            {
              id: 2,
              content: '123论文45',
            },
            {
              id: 3,
              content: '123论文12',
            },
          ],
        },
      ],
    },

    {
      token: 'Admin Token',
      primaryId: 7, //二级分类名称：运营商
      city: [
        {
          id: 9,
          property: '中医医疗',
          propertyTitle1: [
            {
              id: 1,
              content: '123论文121',
            },
            {
              id: 2,
              content: '123论文45',
            },
            {
              id: 3,
              content: '123论文12',
            },
          ],
        },
        {
          id: 10,
          property: '西医医疗',
          propertyTitle1: [
            {
              id: 1,
              content: '123论文121',
            },
            {
              id: 2,
              content: '123论文45',
            },
            {
              id: 3,
              content: '123论文12',
            },
          ],
        },
        {
          id: 11,
          property: '中西医疗设备',
          propertyTitle1: [
            {
              id: 1,
              content: '123论文121',
            },
            {
              id: 2,
              content: '123论文45',
            },
            {
              id: 3,
              content: '123论文12',
            },
          ],
        },
      ],
    },
    {
      token: 'Admin Token',
      primaryId: 8, //二级分类名称：内上衣
      city: [
        {
          id: 9,
          property: '中医医疗',
          propertyTitle1: [
            {
              id: 1,
              content: '123论文121',
            },
            {
              id: 2,
              content: '123论文45',
            },
            {
              id: 3,
              content: '123论文12',
            },
          ],
        },
        {
          id: 10,
          property: '西医医疗',
          propertyTitle1: [
            {
              id: 1,
              content: '123论文121',
            },
            {
              id: 2,
              content: '123论文45',
            },
            {
              id: 3,
              content: '123论文12',
            },
          ],
        },
        {
          id: 11,
          property: '中西医疗设备',
          propertyTitle1: [
            {
              id: 1,
              content: '123论文121',
            },
            {
              id: 2,
              content: '123论文45',
            },
            {
              id: 3,
              content: '123论文12',
            },
          ],
        },
      ],
    },
  ]
}

export default [
  // 返回一级分类
  {
    url: '/api/product/attr/primary', //请求地址
    method: 'get', //请求方式
    response: (request) => {
      const token = request.headers.token
      const result = getPrimaryClassification().find(
        (item) => item.token === token,
      )

      //没有用户返回失败信息
      if (!result) {
        return { code: 201, message: '无数据', ok: false, data: null }
      }
      //如果有返回成功信息
      return { code: 200, message: null, ok: true, data: result.city }
    },
  },

  // 返回二级分类
  {
    url: '/api/product/attr/secondary', //请求地址
    method: 'get', //请求方式
    response: (data) => {
      const primaryId = data.query.id as number
      const result = getSecondaryClassification().find(
        (item) => item.primaryId == primaryId,
      )

      //没有用户返回失败信息
      if (!result) {
        return { code: 201, message: '无数据', ok: false, data: null }
      }
      //如果有返回成功信息
      return { code: 200, message: null, ok: true, data: result.city }
    },
  },

  // 返回三级分类
  {
    url: '/api/product/attr/reclassify', //请求地址
    method: 'get', //请求方式
    response: (data) => {
      const primaryId = data.query.id as number
      const result = getReclassifClassification().find(
        (item) => item.primaryId == primaryId,
      )

      //没有用户返回失败信息
      if (!result) {
        return { code: 201, message: '无数据', ok: false, data: null }
      }
      //如果有返回成功信息
      return { code: 200, message: null, ok: true, data: result.city }
    },
  },

  // 返回属性信息
  {
    url: '/api/product/attr/propertyData', //请求地址
    method: 'get', //请求方式
    response: (data) => {
      const primaryId = data.query.id as number
      const result = getPropertyData().find(
        (item) => item.primaryId == primaryId,
      )

      //没有用户返回失败信息
      if (!result) {
        return { code: 201, message: '无数据', ok: false, data: null }
      }
      //如果有返回成功信息
      return { code: 200, message: null, ok: true, data: result.city }
    },
  },
]
